package com.sxm.yiwei.adapters;

import android.content.Context;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;

import com.alibaba.fastjson.JSONArray;
import com.sxm.yiwei.R;
import com.sxm.yiwei.activitis.FWContentActivity;
import com.sxm.yiwei.utils.InternetAddressUtis;

import org.xutils.x;

/**
 * Created by KuKa on 2017/9/5.
 * 服务详情展示图片
 */

public class FWContentImgAdapter extends BaseAdapter {
    private String TAG ="FWA";
    Context context;
    JSONArray showImages;
    public FWContentImgAdapter(Context context, JSONArray showImages) {
        this.context = context;
        this.showImages=showImages;
    }

    @Override
    public int getCount() {
        return showImages.size();
    }

    @Override
    public Object getItem(int position) {
        return showImages.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        View view;
        ViewHolder holder;
        if (convertView==null){
            view = View.inflate(context, R.layout.content_imgitem,null);
            holder = new ViewHolder();

            holder.img = (ImageView) view.findViewById(R.id.fwcontent_imgitem);
            view.setTag(holder);
        }else {
            view = convertView;
            holder = (ViewHolder) view.getTag();
        }
        x.image().bind(holder.img, InternetAddressUtis.IMG_URL+showImages.get(position));
        return view;
    }

    class ViewHolder{
        ImageView img;
    }
}
